<script setup>
import DetailContainer from "@/components/AdminConponents/DetailContainer.vue";
import {useRoute, useRouter} from "vue-router";
import {onMounted, ref} from "vue";
import { formatTime } from '@/utils/format'
import {publisherGetAPI} from "@/api/AdminApi/publisher.js";

const route = useRoute()
const publisherInfo = ref({})
const getPublisherInfo = async (id = route.params.id) => {
  const res = await publisherGetAPI(id)
  publisherInfo.value = res.data
}
onMounted(() => getPublisherInfo())

// 编辑发行商
const router = useRouter()
const handleEdit = (id) => {
  router.push(`/admin/publisher/edit/${id}`)
}
</script>

<template>
  <DetailContainer title="发行商详情">
    <template #headerRight>
      <el-button @click="handleEdit(publisherInfo.id)" type="success">编辑发行商</el-button>
    </template>
    <template #bodyTop>
      <el-descriptions border :column="1" :title="`${publisherInfo.name}的信息`">
        <el-descriptions-item label="名称">{{ publisherInfo.name }}</el-descriptions-item>
        <el-descriptions-item label="头像">
          <el-image style="width: 100px; height: 100px" :src="publisherInfo.icon"></el-image>
        </el-descriptions-item>
        <el-descriptions-item label="创建日期">{{ publisherInfo.createDate }}</el-descriptions-item>
        <el-descriptions-item label="关注者">{{ publisherInfo.followers }}</el-descriptions-item>
        <el-descriptions-item label="社交账号链接"><a :href="publisherInfo.link">{{ publisherInfo.link }}</a></el-descriptions-item>
        <el-descriptions-item label="发行商简介">{{ publisherInfo.introduction }}</el-descriptions-item>
      </el-descriptions>
    </template>
    <template #bodyBottom>
      <el-descriptions border :column="4">
        <el-descriptions-item label="创建时间">{{formatTime(publisherInfo.createTime)}}</el-descriptions-item>
        <el-descriptions-item label="修改时间">{{formatTime(publisherInfo.updateTime)}}</el-descriptions-item>
        <el-descriptions-item label="创建人">{{publisherInfo.createUser}}</el-descriptions-item>
        <el-descriptions-item label="修改人">{{publisherInfo.updateUser}}</el-descriptions-item>
      </el-descriptions>
    </template>
  </DetailContainer>
</template>

<style scoped>

</style>
